package com.sgcc.statistics.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sgcc.common.log.annotation.Log;
import com.sgcc.common.log.enums.BusinessType;
import com.sgcc.common.security.annotation.PreAuthorize;
import com.sgcc.statistics.domain.OBusiScale;
import com.sgcc.statistics.service.IOBusiScaleService;
import com.sgcc.common.core.web.controller.BaseController;
import com.sgcc.common.core.web.domain.AjaxResult;
import com.sgcc.common.core.utils.poi.ExcelUtil;
import com.sgcc.common.core.web.page.TableDataInfo;

/**
 * 业务线上转化规模Controller
 * 
 * @author sgcc
 * @date 2021-03-28
 */
@RestController
@RequestMapping("/busiscale")
public class OBusiScaleController extends BaseController
{
    @Autowired
    private IOBusiScaleService oBusiScaleService;

    /**
     * 查询业务线上转化规模列表
     */
    //@PreAuthorize(hasPermi = "statistics:busiscale:list")
    @GetMapping("/list")
    public TableDataInfo list(OBusiScale oBusiScale)
    {
        startPage();
        List<OBusiScale> list = oBusiScaleService.selectOBusiScaleList(oBusiScale);
        return getDataTable(list);
    }

    /**
     * 导出业务线上转化规模列表
     */
    //@PreAuthorize(hasPermi = "statistics:busiscale:export")
    @Log(title = "业务线上转化规模", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OBusiScale oBusiScale) throws IOException
    {
        List<OBusiScale> list = oBusiScaleService.selectOBusiScaleList(oBusiScale);
        ExcelUtil<OBusiScale> util = new ExcelUtil<OBusiScale>(OBusiScale.class);
        util.exportExcel(response, list, "busiscale");
    }

    /**
     * 获取业务线上转化规模详细信息
     */
    //@PreAuthorize(hasPermi = "statistics:busiscale:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(oBusiScaleService.selectOBusiScaleById(id));
    }

    /**
     * 新增业务线上转化规模
     */
    //@PreAuthorize(hasPermi = "statistics:busiscale:add")
    @Log(title = "业务线上转化规模", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OBusiScale oBusiScale)
    {
        return toAjax(oBusiScaleService.insertOBusiScale(oBusiScale));
    }

    /**
     * 修改业务线上转化规模
     */
    //@PreAuthorize(hasPermi = "statistics:busiscale:edit")
    @Log(title = "业务线上转化规模", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OBusiScale oBusiScale)
    {
        return toAjax(oBusiScaleService.updateOBusiScale(oBusiScale));
    }

    /**
     * 删除业务线上转化规模
     */
    //@PreAuthorize(hasPermi = "statistics:busiscale:remove")
    @Log(title = "业务线上转化规模", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(oBusiScaleService.deleteOBusiScaleByIds(ids));
    }
}
